package basic;

/**
 * @Author: 海琳琦
 * @Date: 2021/8/29 16:02
 */
public class Title605 {
    public static void main(String[] args) {
        int[] flowerbed = {1,0,0,0,0,1};
        int n = 2;
        System.out.println(canPlaceFlowers(flowerbed, n));
    }

    private static boolean canPlaceFlowers(int[] flowerbed, int n) {
        for (int i = 0; i < flowerbed.length; i++) {
            if(flowerbed[i]==0&&(i+1==flowerbed.length||flowerbed[i+1]==0)){
                n--;
                i++;
            }else if(flowerbed[i]==1){
                i++;
            }
        }
        return n<=0;
    }
}
